package cn.edu.scnu.semart.order.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderStatMapper {
    @Select("SELECT a.province AS region, COUNT(o.order_id) AS sales " +
            "FROM `order` o JOIN address a ON o.address_id = a.address_id " +
            "GROUP BY a.province")
    List<Map<String, Object>> countOrderByProvince();

    @Select("SELECT DATE(o.create_time) AS date, COUNT(o.order_id) AS orderCount, IFNULL(SUM(o.total_price),0) AS totalAmount " +
            "FROM `order` o GROUP BY DATE(o.create_time) ORDER BY DATE(o.create_time)")
    List<Map<String, Object>> countOrderDaily();
}